package com.openness.example.crawler;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Rain
 * @version 2013-5-15 上午9:59:33
 */

public class Statistic {

	private static int allUrl = 0;

	private static int crawlerUrl = 0;

	private static int crawlerPageSuccess = 0;

	private static int crawlerDataSuccess = 0;

	private static final SimpleDateFormat SDF = new SimpleDateFormat(
			"yyyy-MM-dd HH:mm:ss");

	public static synchronized void addAllUrl() {
		allUrl++;
	}

	public static synchronized void addCrawlerUrl() {
		crawlerUrl++;
	}

	public static synchronized void addCrawlerPageSuccess() {
		crawlerPageSuccess++;
	}

	public static synchronized void addCrawlerDataSuccess() {
		crawlerDataSuccess++;
	}

	public static void stat() {
		System.out.println(Thread.currentThread().getName() + "\t"
				+ SDF.format(new Date(System.currentTimeMillis())) + "\t"
				+ "allUrl: " + allUrl + "\t" + "crawlerUrl: " + crawlerUrl
				+ "\t" + "crawlerPageSuccess: " + crawlerPageSuccess + "\t"
				+ "crawlerDataSuccess: " + crawlerDataSuccess);
	}

}
